<? Phpr_View::beginBlock("head") ?>
	<link rel="stylesheet" href="modules/cms/resources/css/resources.css?<?= module_build('cms') ?>" type="text/css"/>
	<link rel="stylesheet" href="phproad/modules/db/behaviors/db_listbehavior/resources/css/list.css?<?= module_build('core') ?>" type="text/css"/>
	<link rel="stylesheet" href="phproad/modules/db/behaviors/db_formbehavior/resources/css/forms.css?<?= module_build('core') ?>" type="text/css"/>
	
	<script type="text/javascript" src="phproad/modules/db/behaviors/db_formbehavior/resources/javascript/Fx.ProgressBar.js"></script>
	<script type="text/javascript" src="phproad/modules/db/behaviors/db_formbehavior/resources/javascript/Swiff.Uploader.js"></script>
	<script type="text/javascript" src="phproad/modules/db/behaviors/db_formbehavior/resources/javascript/FancyUpload2.js"></script>
	<script type="text/javascript" src="phproad/modules/db/behaviors/db_formbehavior/resources/javascript/fileuploader.js"></script>
<? Phpr_View::endBlock() ?>

<? Phpr_View::beginBlock("view") ?>
	<? if (!isset($fatalError)): ?>
		<table class="file_browser">
			<tr>
				<th>
					<div class="toolbar">
						<?= Phpr_Form::openTag() ?>
							<?= backend_ctr_button('New folder', 'folder_add', array('href'=>'#', 'onclick'=>"new PopupForm('index_onShowNewFoldeForm', {ajaxFields: {dir: $('current_folder').get('value')}}); return false;")) ?>
							<?= backend_ctr_button('Rename', 'folder_edit', array('href'=>'#', 'onclick'=>"new PopupForm('index_onShowRenameFolderForm', {ajaxFields: {dir: $('current_folder').get('value')}}); return false;")) ?>
							<?= backend_ctr_button('Delete', 'folder_delete', array('href'=>'#', 'onclick'=>"new PopupForm('index_onShowDeleteFoldeForm', {ajaxFields: {dir: $('current_folder').get('value')}}); return false;")) ?>
							<div class="clear"></div>
						</form>
					</div>

					<?= Phpr_Form::openTag(array('id'=>'folder_list_form')) ?>
						<div class="folderList" id="folder_list">
							<? $this->renderPartial('folder_list') ?>
						</div>
					</form>
				</th>
				<td>
					<div class="toolbar">
						<?= Phpr_Form::openTag(array('id'=>'folders_form')) ?>
							<?= backend_ctr_button('New file', 'new_document', array('href'=>'#', 'onclick'=>"new PopupForm('index_onShowNewFileForm', {ajaxFields: {dir: $('current_folder').get('value')}}); return false;")) ?>
							<?= backend_ctr_button('Upload file(s)', 'document_import', array('href'=>'#', 'onclick'=>"new PopupForm('index_onShowUploadForm', {ajaxFields: {dir: $('current_folder').get('value')}}); return false;")) ?>
							<?= backend_ctr_ajax_button('Delete selected', 'delete_document', 'index_onDeleteSelected', array(), 
								"loadIndicator: {show: false}, 
								extraFields: $('file_list'),
								preCheckFunction: function()
									{
										if (!$('file_list').getElements('input.file_list_cb').some(
											function(element) {return element.checked}
										)) {alert('Please select file(s) to delete.'); return false;} return true;
									},
								confirm: 'Do you really want to delete selected file(s)?'
								"
							) ?>
							<?= backend_ctr_button('Move selected', 'move', array('href'=>'#', 'onclick'=>"if (!$('file_list').getElements('input.file_list_cb').some(
								function(element) {return element.checked}
							)) {alert('Please select file(s) to move.'); return false;} new PopupForm('index_onShowMoveForm', {ajaxFields: $('file_list')}); return false;")) ?>
							
							<?= Backend_Html::ctr_menuButton('Set view mode...  ', 'view', array(
								'Table'=>array('href'=>"#", 'class'=>'view_columns', 'onclick'=>"return $(this).getForm().sendPhpr('index_onSetViewSettings', {loadIndicator: {show: false}, onBeforePost: LightLoadingIndicator.show.pass('Loading...'), onComplete: LightLoadingIndicator.hide, extraFields: {'view_type': 'table', dir: $('current_folder').get('value')}})"), 
								'Icons'=>array('href'=>"#", 'class'=>'view_icons', 'onclick'=>"return $(this).getForm().sendPhpr('index_onSetViewSettings', {loadIndicator: {show: false}, onBeforePost: LightLoadingIndicator.show.pass('Loading...'), onComplete: LightLoadingIndicator.hide, extraFields: {'view_type': 'icons', dir: $('current_folder').get('value')}})"), 
								'Thumbnails'=>array('href'=>"#", 'class'=>'view_thumbnails', 'onclick'=>"return $(this).getForm().sendPhpr('index_onSetViewSettings', {loadIndicator: {show: false}, onBeforePost: LightLoadingIndicator.show.pass('Loading...'), onComplete: LightLoadingIndicator.hide, extraFields: {'view_type': 'thumbnails', dir: $('current_folder').get('value')}})")) 
							) ?>
							<div class="clear"></div>
						</form>
					</div>

					<?= Phpr_Form::openTag(array('id'=>'file_list_form')) ?>
						<div id="file_list">
							<? $this->renderPartial('file_list') ?>
						</div>
					</form>
				</td>
			</tr>
		</table>
	<? else: ?>
		<?= flash() ?>
	<? endif ?>

<? Phpr_View::endBlock() ?>